/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.draw;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Ellipse2D;
import java.util.Vector;

/**
 * @author Moreira, Renata & Pitangueira, Roque
 * @since July 2005
 */
public class GaussPointDraw extends Draw{
    private Object owner;

//*****************************************************************************
	
    public GaussPointDraw() {
        this(new Point(0, 0));
    }
    
//*****************************************************************************
	
    public GaussPointDraw(Point loc) {
        this(loc, null);
    }
	
//*****************************************************************************
	
    public GaussPointDraw(Point loc, Object represents) {
        this.setLocation(loc);
        this.setRepresents(represents);
    }
	
    public GaussPointDraw(Point loc, Object represents, Object owner) {
        this.setLocation(loc);
        this.setRepresents(represents);
        this.setOwner(owner);
    }
    
//*****************************************************************************
	
    public Vector<Object> getShapes() {
        return null;
    }
    
//*****************************************************************************
	
    /**
     * Draws in a given Graphics.
     *
     * @see   java.awt.Graphics
     */
    public void draw(Graphics2D g2) {
        
        int x = this.getLocation().x;
        int y = this.getLocation().y;
        int width = this.getSize().width;
        int height = this.getSize().height;
        double scale = this.getScale();
        
        int W = (int)(width * scale);
        int H = (int)(height * scale); 
        
        g2.fill(new Ellipse2D.Double((int)(x - W/2), (int)(y - H/2), W, H));
        if (!this.getLabel().equals("")) {
            g2.drawString(this.getLabel(), (int)(x + W), (int)(y - H));
        }
        
        Color currentColor = g2.getColor();
        
        if (isSelected()) {
            g2.setColor(new Color(255, 0, 0));
            g2.draw(getBounds());
        }
        
        g2.setColor(currentColor);
    } 
    
//*****************************************************************************
	
    /**
     * Returns the draw bounds in device units.
     *
     * @return the draw bounds
     */
    public Rectangle getBounds() {
        
        int x = this.getLocation().x;
        int y = this.getLocation().y;
        int width = this.getSize().width;
        int height = this.getSize().height;
        double scale = this.getScale();
		
        int W = (int)(4 + width * scale);
        int H = (int)(4+ height * scale); 
        return new Rectangle((int)(x - W/2), (int)(y - H/2), W, H);
    }
	
    /**
     * @return Returns the owner.
     */
    public Object getOwner() {
        return owner;
    }
    
    /**
     * @param owner The owner to set.
     */
    public void setOwner(Object owner) {
        this.owner = owner;
    }
}

